package com.itheima.mapper;

import com.itheima.pojo.Game;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Name GameMapper
 * @Author BaiXin
 * @Date 2022-10-21 20:58
 */

public interface GameMapper {
    /**
     *
     * @return
     */
    @Select("select * from tb_game")
    List<Game> findAll();

    /**
     * 插入
     * @param game
     */
    @Insert("insert into tb_game (name, type, url, ordered, company) " +
            "values (#{name},#{type},#{url},#{ordered},#{company})")
    void save(Game game);

    /**
     * 修改
     * @param game
     */
    @Update("update tb_game set name = #{name},type=#{type}, url=#{url},ordered=#{ordered},company=#{company} where id = #{id}")
    void update(Game game);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from tb_game where id = #{id};")
    void deleteById(Integer id);
}
